/**
 * 项目日志
 */
let event = Promise.resolve((r) => setTimeout(r))
let style =
	'border: 1px #000 solid;font-size:10px;padding: 0px 5px;border-radius: 5px;background-color: #333;color: #F0AD4E;'
class Log {
	static getInstance() {
		if (!this.instance) {
			this.instance = new Log();
		}
		return this.instance;
	}
	constructor() {}
	log(...text) {
		let perlogtext = this.config.perlogtext || ''
		if (this.config.silent) {
			event.then((r) => r(console.log.bind(console, `%c${perlogtext}`, style, ...text)))
		}
	}
	error(...text) {
		let perlogtext = this.config.perlogtext || ''
		if (this.config.silent) {
			event.then((r) => r(console.error.bind(console, `%c${perlogtext}`, style, ...text)))
		}
	}
	warn(...text) {
		let perlogtext = this.config.perlogtext || ''
		if (this.config.silent) {
			event.then((r) => r(console.warn.bind(console, `%c${perlogtext}`, style, ...text)))
		}
	}
	info(...text) {
		let perlogtext = this.config.perlogtext || ''
		if (this.config.silent) {
			event.then((r) => r(console.info.bind(console, `%c${perlogtext}`, style, ...text)))
		}
	}

}

let logObj = Log.getInstance()
export const log = logObj.log
export const error = logObj.error
export const warn = logObj.warn
export const info = logObj.info
